<template>
  <div class="Search">
    <van-row>
      <van-col
        span="2"
        offset="1"
        style="padding-top:5px"
        class="top"
      >
        <van-image
          v-if="$store.state.user==''"
          round
          width="1.1rem"
          height="1.1rem"
          fit="contain"
          src="https://img1.baidu.com/it/u=1703711924,229959213&fm=253&fmt=auto&app=120&f=PNG?w=192&h=192"
          @click="look"
        />
        <van-image
          v-else
          round
          width="1.1rem"
          height="1.1rem"
          fit="contain"
          :src="'apis/kuan_api/photo/'+$store.state.user.user_img"
          @click="look"
          style="border:1px solid lightgray"
        />
      </van-col>
      <van-col
        span="13"
        offset="1"
        class="s_box"
      >
        <van-search
          v-model="search"
          placeholder="旧机博物馆"
        />
      </van-col>
      <van-col
        span="1"
        offset="1"
        class="icon"
      >
        <van-icon name="bag-o" />
      </van-col>
      <van-col
        span="1"
        offset="1"
        class="icon"
      >
        <van-icon name="chat-o" />
      </van-col>
      <van-col
        span="1"
        offset="1"
        class="icon"
      >
        <van-icon
          name="add"
          color="green"
          @click="sendmessage"
        />
      </van-col>
    </van-row>
  </div>
</template>

<script>
export default {
  name: "Search",
  data() {
    return {
      search: "",
    };
  },
  methods: {
    look() {
      console.log(this.$store.state.user.user_id);
      if (this.$store.state.user.user_id == undefined) {
        this.$dialog
          .confirm({
            title: "提示",
            message: "当前还未登录",
          })
          .then(() => {
            this.$router.push("/login");
          });
      } else {
        this.$router.push({
          path: "/userdetail",
          query: {
            userid: this.$store.state.user.user_id,
          },
        });
      }
    },
    sendmessage() {
      if (this.$store.state.user.user_id == undefined) {
        this.$dialog
          .confirm({
            title: "提示",
            message: "当前还未登录",
          })
          .then(() => {
            this.$router.push("/login");
          });
      }else{
        this.$router.push('/sendmessage')
      }
    },
  },
};
</script>

<style scoped>
.Search {
  /* display: flex;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  z-index: 9999; */
  border-bottom: 1px solid lightgray;
}
.icon {
  font-size: 0.5rem;
  padding-top: 15px;
}
.s_box {
  font-size: 0.6rem;
  padding-top: 0.05rem;
}
.add {
  color: green;
}
</style>